Skip to content

Linter: Fix erb-no-trailing-whitespace autofix at end of file - #2923

Merged
marcoroth merged 1 commit into
marcoroth:mainfrom
davidenglishmusic:erb-no-trailing-whitespace-end-of-file
Nov 26, 2026
Merged

marcoroth merged 1 commit into
marcoroth:mainfrom
davidenglishmusic:erb-no-trailing-whitespace-end-of-file

Conversation

@davidenglishmusic

@davidenglishmusic davidenglishmusic commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The autofix treated whitespace after a newline as indentation and kept it. On the last line of a file there is nothing to indent, so the trailing whitespace stayed and the offense was still reported as fixed even though nothing changed.

Summary by CodeRabbit

  • Bug Fixes
    • Trailing whitespace at the end of a document is now removed correctly by autofix, including whitespace in the final HTML text or literal content.
    • A whitespace-only final line without a trailing newline is removed while preserving the preceding newline; files containing only spaces are cleared.
  • Tests
    • Added coverage for end-of-document autofixes, including verification that the final-line fix leaves no remaining lint offenses.

@github-actions github-actions Bot added linter @herb-tools/linter for HTML+ERB templates typescript TypeScript source across the javascript/ packages linter-rule Individual linter rules and their documentation linter-autofix Linter autofix behavior labels Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The ERB trailing-whitespace autofix now handles HTML text and literal nodes at the end of the document. New tests cover a whitespace-only final line without a newline and a file containing only spaces.

Changes: End-of-file whitespace autofix

Layer / File(s) Summary
Detect and fix end-of-file whitespace
javascript/packages/linter/src/rules/erb-no-trailing-whitespace.ts, javascript/packages/linter/test/autofix/erb-no-trailing-whitespace.autofix.test.ts
The rule detects HTML text and literal nodes that end at the document’s final position. Tests cover removing whitespace from a final line and clearing a whitespace-only file.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: markokajzer, marcoroth

Merge Risk: Minimal · up to 2b94e

This fixes the autofix leaving trailing whitespace on the final line of a file while reporting it as fixed. Tests cover the affected cases, and no remaining merge-blocking risk was found.

Security architecture risk: Minimal · up to 2b94e

The change removes whitespace from document endings through the existing autofix flow. No introduced or worsened risk affecting security, failure containment, rollback, or ownership was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the ERB no-trailing-whitespace rule and the end-of-file autofix, which is the main change in the changeset: the autofix now trims trailing whitespace at the document end, and tests cov…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the ERB no-trailing-whitespace rule and the end-of-file autofix, which is the main change in the changeset: the autofix now trims trailing whitespace at the document end, and tests cover whitespace-only final lines and empty-after-fix files. The title is specific and matches the PR objectives.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81b26e6d-37e6-44ee-b9f8-f6f8bfd0071a
Commits

Reviewing files that changed from the base of the PR and between dd7cabe and 2b94e7c.

Files selected for processing: 2

  • javascript/packages/linter/src/rules/erb-no-trailing-whitespace.ts
  • javascript/packages/linter/test/autofix/erb-no-trailing-whitespace.autofix.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@marcoroth marcoroth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davidenglishmusic! 🙏🏼

@marcoroth
marcoroth merged commit 9b42ca5 into marcoroth:main Nov 26, 2026
19 checks passed
@davidenglishmusic
davidenglishmusic deleted the erb-no-trailing-whitespace-end-of-file branch November 26, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linter @herb-tools/linter for HTML+ERB templates linter-autofix Linter autofix behavior linter-rule Individual linter rules and their documentation typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants